from datetime import datetime

from pydantic import BaseModel


class UserBase(BaseModel):
    nickname: str | None = None


class User(UserBase):
    phone: str
    id: int


class UserCreate(UserBase):
    phone: str
    pushId: str
    deviceId: str


class UserUpdate(UserBase):
    pushId: str | None = None


class RecordBase(BaseModel):
    fee: float
    category: str
    description: str | None
    card_id: int | None


class Record(RecordBase):
    id: int
    created_at: datetime
    updated_at: datetime
    metadata: dict


class CategoryBase(BaseModel):
    name: str


class Category(CategoryBase):
    id: int
    created_at: datetime
    updated_at: datetime


class ProjectBase(BaseModel):
    name: str
    rate: float
    fee: float
    income: float
    startTime: datetime
    endTime: datetime


class Project(ProjectBase):
    id: int
    user: User
    created_at: datetime
    updated_at: datetime


class CardBase(BaseModel):
    fee: float
    bank: str


class Card(CardBase):
    id: int
    user: User
    created_at: datetime
    updated_at: datetime


class FamilyBase(BaseModel):
    nickname: str


class FamilyCreate(BaseModel):
    family: User


class Family(FamilyBase):
    id: int
    family: User
    created_at: datetime
    updated_at: datetime


class App(BaseModel):
    id: int
    version: str
    platform: str
    androidUrl: str
    appleStore: str
    created_at: datetime
